<template>
  <keep-alive>
    <component :is="componentName" @menu-select="menuSelect" />
  </keep-alive>
</template>

<script>
  import roiMoneyIndex from './index'
  import putinStatisticsIndex from '../putinStatistics'

  import {
    mapGetters
  } from 'vuex'
  export default {
    name: 'roiMoneyAllIndex',
    components: {
      roiMoneyIndex,
      putinStatisticsIndex

    },
    props: {},
    data() {
      return {
        componentName: ''
      }
    },
    computed: {
      ...mapGetters(['crm'])
    },
    watch: {},
    mounted() {
      if (this.crm && this.crm.roiMoney) {
        this.componentName = 'roiMoneyIndex'
      } else if (this.crm && this.crm.putinStatistics) {
        this.componentName = 'putinStatisticsIndex'
      }
    },

    beforeDestroy() {},
    methods: {
      /**
       * 左侧菜单选择
       */
      menuSelect(key, keyPath) {
        // console.log(key, keyPath)
        this.componentName = {
          roiMoney: 'roiMoneyIndex',
          putinStatistics: 'putinStatisticsIndex',
        } [key]
      }
    }
  }
</script>

<style lang="scss" scoped>
</style>
